<template>
	<view>
		<view class="form_list">
			<view class="list-detail font-red">
				Tip：长按文字可复制
			</view>
		</view>
		
		<view v-if="user!=undefined?true:false">
			<view class="form_list">
				<view class="label_round">登录账号:</view>
				<view class="list-detail" @longpress="copyText(user.username)">
					{{user.username}}
				</view>
			</view>
			<view class="form_list">
				<view class="label_round">所选仓库:</view>
				<view class="list-detail" @longpress="copyText(user.stock_name)">
					{{user.stock_name}}
				</view>
			</view>
		</view>
		
		<view class="form_list">
			<view class="label_round">当前版本:</view>
			<view class="list-detail" @longpress="copyText(version)">
				{{version}}
			</view>
		</view>
		<view class="form_list">
			<view class="label">软件名称:</view>
			<view class="list-detail" >
				蓬盛WMS
			</view>
		</view>
		<view class="form_list">
			<view class="label_round">设备标识:</view>
			<view class="list-detail wrap" @longpress="copyText(uuid)" @click="tosend()">
				{{uuid}}
			</view>
		</view>
	</view>
</template>

<script>
// 引入uni-ui组件
import {
  uniIcons
} from "@dcloudio/uni-ui"
export default {
  data() {
    return {
		user:'',
		uuid:'',
		version:'',
		syntime:''
    }
  },
  components: {
	uniIcons
  },
  onShow(){
	  this.user = uni.getStorageSync('user'),
	  this.uuid = uni.getStorageSync('uuid'),
	  this.version = uni.getAppBaseInfo().appWgtVersion,
	  this.syntime = uni.getStorageSync('syntime')
  },
  methods: {
   copyText(textToCopy) {
         if (uni.getSystemInfoSync().platform === 'android') {
           const ClipboardManager = plus.android.importClass('android.text.ClipboardManager');
           const context = plus.android.runtimeMainActivity();
     
           // 获取剪贴板管理器
           const clipboardManager = context.getSystemService(context.CLIPBOARD_SERVICE);
     
           // 复制文本到剪贴板
           clipboardManager.setText(textToCopy);
     
           uni.showToast({
             title: '已复制到剪贴板',
             icon: 'success'
           });
         } else {
           uni.showToast({
             title: '该功能仅支持 Android 平台',
             icon: 'none'
           });
         }
       },
	   tosend(){
	   		   this.$Db.addlog('设备标识',this.uuid)
	   		   this.$Api.msg('已发送到WMS平台,请返回首页')
	   }
  }
}
</script>
<style lang="less">
.wrap{
	word-wrap: break-word;
	word-break: break-all;
}
</style>